1
'****************************** Module Header ******************************\
2 ' Module Name: CustomTreeView.vb
3 ' Project: VBASPNETInheritingFromTreeNode
4 ' Copyright (c) Microsoft Corporation
6 ' This file defines a CustomTreeView control which's tree nodes contain a Tag
7 ' property. The Tag property can be used to store a custom object.
9 ' This source is subject to the Microsoft Public License.
10 ' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
11 ' All other rights reserved.
13 '*****************************************************************************/
15 Public Class CustomTreeView
18 ''' Returns a new instance of the TreeNode class. The CreateNode is a helper method.
20 Protected Overrides
Function CreateNode() As TreeNode
21 Return New CustomTreeNode(Me, False)
25 Public Class CustomTreeNode
28 ''' Gets or sets the object that contains data about the tree node.
30 Public Property Tag
As Object
36 Public Sub New(ByVal owner
As TreeView
, ByVal isRoot
As Boolean)
37 MyBase
.New(owner
, isRoot
)
41 ''' Restores view-state information from a previous page request that
42 ''' was saved by the SaveViewState method.
44 ''' <param name="state">
45 ''' An Object that represents the control state to be restored.
47 Protected Overrides
Sub LoadViewState(ByVal state
As Object)
48 Dim arrState
As Object() = TryCast(state
, Object())
51 MyBase
.LoadViewState(arrState(1))
55 ''' Saves any server control view-state changes that have occurred
56 ''' since the time the page was posted back to the server.
59 ''' Returns the server control's current view state. If there is no
60 ''' view state associated with the control, this method returns null.
62 Protected Overrides
Function SaveViewState() As Object
63 Dim arrState
As Object() = New Object(1) {}
64 arrState(1) = MyBase
.SaveViewState()